/************************************************************************
 *   IRC - Internet Relay Chat, ircd/s_err.c
 *   Copyright (C) 1992 Darren Reed
 *   Copyright (C) 1999 Maarten van den Bosch
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 1, or (at your option)
 *   any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "struct.h"
#include "numeric.h"
#include "h.h"

typedef struct
{
    int num_val;
    char *num_form;
}
Numeric;

static char *prepbuf PROTO ((char *, int, char *));
static char numbuff[514];
static char numbers[] = "0123456789";

static Numeric local_replies[] = {
/* 000 */
    {0, (char *) NULL},
/* 001 */
    {RPL_WELCOME, ":Hello %s, Welcome to the " irc_network " IRC Network!"},
/* 002 */
    {RPL_YOURHOST, ":Your host is %s, running version %s"},
/* 003 */
    {RPL_CREATED, ":This server was created on %s"},
/* 004 */
    {RPL_MYINFO, "%s %s aAcfgiIjkMnNoORstxy bceHiIklmnorRstv"},
/* 005 */
    {RPL_PROTOCTL, "%s :are available on this server"},
/* 006 */
    {RPL_MAP, ":%s%-*s (Users:%5d)  (%2d%%)"},
/* 007 */
    {RPL_MAPEND, ":End of /MAP"},
    {0, (char *) NULL}
};

static Numeric numeric_errors[] = {
/* 401 */
    {ERR_NOSUCHNICK, "%s :No such nickname/channel"},
/* 402 */
    {ERR_NOSUCHSERVER, "%s :No such server"},
/* 403 */
    {ERR_NOSUCHCHANNEL, "%s :No such channel"},
/* 404 */
    {ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (%s)"},
/* 405 */
    {ERR_TOOMANYCHANNELS, "%s :You have joined too many channels"},
/* 406 */
    {ERR_WASNOSUCHNICK, "%s :There was no such nickname"},
/* 407 */
    {ERR_TOOMANYTARGETS, "%s :Duplicate recipients. No message delivered"},
/* 408 */
    {ERR_NOSUCHSERVICE, (char *) NULL},
/* 409 */
    {ERR_NOORIGIN, ":No origin specified"},
/* 410 */
    {ERR_CANNOTKNOCK, ":Cannot knock on %s (%s)"},
/* 411 */
    {ERR_NORECIPIENT, ":No recipient given (%s)"},
/* 412 */
    {ERR_NOTEXTTOSEND, ":No text to send"},
/* 413 */
    {ERR_NOTOPLEVEL, "%s :No toplevel domain specified"},
/* 414 */
    {ERR_WILDTOPLEVEL, "%s :Wildcard in toplevel Domain"},
/* 415 */
    {ERR_SERVICESUP,
     "%s :Denied, This command cannot be executed while services are online."},
/* 416 */
    {0, (char *) NULL},
/* 417 */
    {0, (char *) NULL},
/* 418 */
    {0, (char *) NULL},
/* 419 */
    {0, (char *) NULL},
/* 420 */
    {0, (char *) NULL},
/* 421 */
    {ERR_UNKNOWNCOMMAND, "%s :Unknown command"},
/* 422 */
    {ERR_NOMOTD, ":MOTD File is missing"},
/* 423 */
    {ERR_NOADMININFO, "%s :No administrative info available"},
/* 424 */
    {ERR_FILEERROR, ":File error doing %s on %s"},
/* 425 */
    {0, (char *) NULL},
/* 426 */
    {0, (char *) NULL},
/* 427 */
    {0, (char *) NULL},
/* 428 */
    {0, (char *) NULL},
/* 429 */
    {0, (char *) NULL},
/* 430 */
    {0, (char *) NULL},
/* 431 */
    {ERR_NONICKNAMEGIVEN, ":No nickname given"},
/* 432 */
    {ERR_ERRONEUSNICKNAME, "%s :Erroneous Nickname: \2%s\2"},
/* 433 */
    {ERR_NICKNAMEINUSE,
     "%s :Nickname is already in use, please choose another."},
/* 434 */
    {ERR_SERVICENAMEINUSE, (char *) NULL},
/* 435 */
    {ERR_SERVICECONFUSED, (char *) NULL},
/* 436 */
    {ERR_NICKCOLLISION, "%s :Nickname collision KILL"},
/* 437 */
    {ERR_BANNICKCHANGE, "%s :Cannot change nickname while banned on channel"},
/* 438 */
    {ERR_NCHANGETOOFAST,
     "%s :Nick change too fast. Please wait \2%d\2 seconds"},
/* 439 */
    {ERR_TARGETTOOFAST,
     "%s :Message target change too fast. Please wait \2%d\2 seconds"},
/* 440 */
    {ERR_SERVICESDOWN,
     "%s :Services is currently down. Please wait a few moments, and then try again."},
/* 441 */
    {ERR_USERNOTINCHANNEL, "%s %s :They aren't on that channel"},
/* 442 */
    {ERR_NOTONCHANNEL, "%s :You're not on that channel"},
/* 443 */
    {ERR_USERONCHANNEL, "%s %s :is already on channel"},
/* 444 */
    {ERR_NOLOGIN, "%s :User not logged in"},
/* 445 */
    {ERR_SUMMONDISABLED, ":SUMMON has been disabled"},
/* 446 */
    {ERR_USERSDISABLED, ":USERS has been disabled"},
/* 447 */
    {0, (char *) NULL},
/* 448 */
    {0, (char *) NULL},
/* 449 */
    {0, (char *) NULL},
/* 450 */
    {0, (char *) NULL},
/* 451 */
    {ERR_NOTREGISTERED, ":You have not registered"},
/* 452 */
    {0, (char *) NULL},
/* 453 */
    {0, (char *) NULL},
/* 454 */
    {0, (char *) NULL},
/* 455 */
    {ERR_HOSTILENAME,
     ":Your username %s contained the invalid character(s) %s and has been changed "
     "to %s. Please use only the characters 0-9 a-z A-Z _ - or . in your username."
     "Your username is the part before the @ in your email address."},
/* 456 */
    {0, (char *) NULL},
/* 457 */
    {0, (char *) NULL},
/* 458 */
    {0, (char *) NULL},
/* 459 */
    {0, (char *) NULL},
/* 460 */
    {0, (char *) NULL},
/* 461 */
    {ERR_NEEDMOREPARAMS, "%s :Not enough parameters"},
/* 462 */
    {ERR_ALREADYREGISTRED, ":You may not reregister"},
/* 463 */
    {ERR_NOPERMFORHOST, ":Your host isn't among the privileged"},
/* 464 */
    {ERR_PASSWDMISMATCH, ":Password Incorrect"},
/* 465 */
    {ERR_YOUREBANNEDCREEP,
     ":You are banned from this server.  Mail " KLINE_ADDRESS
     " for more information"},
/* 466 */
    {ERR_YOUWILLBEBANNED, (char *) NULL},
/* 467 */
    {ERR_KEYSET, "%s :Channel key already set"},
/* 468 */
    {ERR_ONLYSERVERSCANCHANGE, "%s :Only servers can change that mode"},
/* 469 */
    {0, (char *) NULL},
/* 470 */
    {0, (char *) NULL},
/* 471 */
    {ERR_CHANNELISFULL, "%s :Cannot join channel because it is full (+l)"},
/* 472 */
    {ERR_UNKNOWNMODE, "%c :is an unknown mode char"},
/* 473 */
    {ERR_INVITEONLYCHAN,
     "%s :Cannot join channel because it is invite only (+i)"},
/* 474 */
    {ERR_BANNEDFROMCHAN,
     "%s :Cannot join channel because you are banned (+b)"},
/* 475 */
    {ERR_BADCHANNELKEY,
     "%s :Cannot join channel as you need a correct key (+k)"},
/* 476 */
    {ERR_BADCHANMASK, "%s :Bad Channel Mask"},
/* 477 */
    {ERR_NEEDREGGEDNICK,
     "%s :Your nickname must be registered and identified with NickServ in order to join this channel. Contact the channel founder or a channel op for assistance."},
/* 478 */
    {ERR_BANLISTFULL, "%s %s :Channel ban/ignore list is full"},
/* 479 */
    {ERR_NEEDREGGEDNICKTOMSG, "%s is only accepting messages from registered nicks."},
/* 480 */
    {ERR_NEEDREGGEDNICKTOCMD, "%s :Your nickname must be registered and identified with NickServ in order to perform this command. "}, //If you need assistance on registering, join #<helproom>"}, -- old
/* 481 */
    {ERR_NOPRIVILEGES,
     ":Permission Denied- You do not have the correct IRC Operator privileges"},
/* 482 */
    {ERR_CHANOPRIVSNEEDED, "%s :Channel Operator status required."},
/* 483 */
    {ERR_CANTKILLSERVER, ":You cant kill a server!"},
/* 484 */
    {ERR_ISROOT, "%s %s :Cannot kick a Services Root Administrator"},
/* 485 */
/* [New Stuff Kei] */
    {ERR_CANTKILLPROT, ":Permission Denied - \2 %s \2 is protected from KILLs."},
/* [End Kei] */
/* 486 */
    {0, (char *) NULL},
/* 487 */
    {0, (char *) NULL},
/* 488 */
    {0, (char *) NULL},
/* 489 */
    {0, (char *) NULL},
/* 490 */
    {0, (char *) NULL},
/* 491 */
    {ERR_NOOPERHOST, ":No O-lines for your host"},
/* 492 */
    {ERR_NOSERVICEHOST, (char *) NULL},
/* 493 */
    {0, (char *) NULL},
/* 494 */
    {0, (char *) NULL},
/* 495 */
    {0, (char *) NULL},
/* 496 */
    {0, (char *) NULL},
/* 497 */
    {0, (char *) NULL},
/* 498 */
    {0, (char *) NULL},
/* 499 */
    {0, (char *) NULL},
/* 500 */
    {0, (char *) NULL},
/* 501 */
    {ERR_UMODEUNKNOWNFLAG, ":Unknown MODE flag"},
/* 502 */
    {ERR_USERSDONTMATCH, ":Can not change mode for other users"},
/* 503 */
    {0, (char *) NULL},
/* 504 */
    {0, (char *) NULL},
/* 505 */
    {0, (char *) NULL},
/* 506 */
    {0, (char *) NULL},
/* 507 */
    {0, (char *) NULL},
/* 508 */
    {0, (char *) NULL},
/* 509 */
    {0, (char *) NULL},
/* 510 */
    {0, (char *) NULL},
/* 511 */
    {ERR_SILELISTFULL, "%s :Your silence list is full"},
/* 512 */
    {ERR_TOOMANYWATCH, "%s :Maximum size for WATCH-list is 128 entries"},
/* 513 */
    {ERR_NEEDPONG, ":To connect, type /QUOTE PONG %lX"},
/* 514 */
    {0, (char *) NULL},
/* 515 */
    {0, (char *) NULL},
/* 516 */
    {0, (char *) NULL},
/* 517 */
    {0, (char *) NULL},
/* 518 */
    {0, (char *) NULL},
/* 519 */
    {0, (char *) NULL},
/* 520 */
    {0, (char *) NULL},
/* 521 */
    {ERR_LISTSYNTAX, "Bad list syntax, type /quote list ? or /raw list ?"},
    {0, (char *) NULL}
};

static Numeric numeric_replies[] = {
/* 300 */
    {RPL_NONE, (char *) NULL},
/* 301 */
    {RPL_AWAY, "%s :%s"},
/* 302 */
    {RPL_USERHOST, ":"},
/* 303 */
    {RPL_ISON, ":"},
/* 304 */
    {RPL_TEXT, (char *) NULL},
/* 305 */
    {RPL_UNAWAY, ":You are no longer marked as being away"},
/* 306 */
    {RPL_NOWAWAY, ":You have been marked as being away"},
/* 307 */
    {0, (char *) NULL},
/* 308 */
    {RPL_WHOISADMIN, "%s :is a Server Administrator"},
/* 309 */
    {RPL_WHOISSADMIN, "%s :is a Services Operator"},
/* 310 */
    {0, (char *) NULL},
/* 311 */
    {RPL_WHOISUSER, "%s %s %s * :%s"},
/* 312 */
    {RPL_WHOISSERVER, "%s %s :%s"},
/* 313 */
    {RPL_WHOISOPERATOR, "%s :is %s"},
/* 314 */
    {RPL_WHOWASUSER, "%s %s %s * :%s"},
/* 315 */
    {RPL_ENDOFWHO, "%s :End of /WHO list."},
/* 316 */
    {RPL_WHOISCHANOP, (char *) NULL},
/* 317 */
    {RPL_WHOISIDLE, "%s %ld %ld :second(s) idle, signon time"},
/* 318 */
    {RPL_ENDOFWHOIS, "%s :End of /WHOIS list."},
/* 319 */
    {RPL_WHOISCHANNELS, "%s :%s"},
/* 320 */
    {0, (char *) NULL},
/* 321 */
    {RPL_LISTSTART, "Channel :Users  Name"},
/* 322 */
    {RPL_LIST, "%s %d :%s"},
/* 323 */
    {RPL_LISTEND, ":End of /LIST"},
/* 324 */
    {RPL_CHANNELMODEIS, "%s %s %s"},
/* 325 */
    {0, (char *) NULL},
/* 326 */
    {0, (char *) NULL},
/* 327 */
    {0, (char *) NULL},
/* 328 */
    {0, (char *) NULL},
/* 329 */
    {RPL_CREATIONTIME, "%s %lu"},
/* 330 */
    {0, (char *) NULL},
/* 331 */
    {RPL_NOTOPIC, "%s :No topic is set."},
/* 332 */
    {RPL_TOPIC, "%s :%s"},
/* 333 */
    {RPL_TOPICWHOTIME, "%s %s %lu"},
/* 334 */
    {RPL_LISTSYNTAX, ":%s"},
/* 335 */
    {0, (char *) NULL},
/* 336 */
    {0, (char *) NULL},
/* 337 */
    {0, (char *) NULL},
/* 338 */
    {0, (char *) NULL},
/* 339 */
    {0, (char *) NULL},
/* 340 */
    {0, (char *) NULL},
/* 341 */
    {RPL_INVITING, "%s %s"},
/* 342 */
    {RPL_SUMMONING, "%s :User summoned to irc"},
/* 343 */
    {0, (char *) NULL},
/* 344 */
    {0, (char *) NULL},
/* 345 */
    {0, (char *) NULL},
/* 346 */
    {RPL_INVITELIST, "%s %s %s %lu"},
/* 347 */
    {RPL_ENDOFINVITELIST, "%s :End of Channel Invite List"},
/* 348 */
    {RPL_EXBANLIST, "%s %s %s %lu"},
/* 349 */
    {RPL_EXBANLISTEND, "%s :End of Channel Exception Ban List"},
/* 350 */
    {0, (char *) NULL},
/* 351 */
    {RPL_VERSION, "%s.%s %s :%s"},
/* 352 */
    {RPL_WHOREPLY, "%s %s %s %s %s %s :%d %s"},
/* 353 */
    {RPL_NAMREPLY, "%s"},
/* 354 */
    {0, (char *) NULL},
/* 355 */
    {0, (char *) NULL},
/* 356 */
    {0, (char *) NULL},
/* 357 */
    {0, (char *) NULL},
/* 358 */
    {0, (char *) NULL},
/* 359 */
    {0, (char *) NULL},
/* 360 */
    {0, (char *) NULL},
/* 361 */
    {RPL_KILLDONE, (char *) NULL},
/* 362 */
    {RPL_CLOSING, "%s :Closed. Status = %d"},
/* 363 */
    {RPL_CLOSEEND, "%d: Connections Closed"},
/* 364 */
    {RPL_LINKS, "%s %s :%d %s"},
/* 365 */
    {RPL_ENDOFLINKS, "%s :End of /LINKS list."},
/* 366 */
    {RPL_ENDOFNAMES, "%s :End of /NAMES list."},
/* 367 */
    {RPL_BANLIST, "%s %s %s %lu"},
/* 368 */
    {RPL_ENDOFBANLIST, "%s :End of Channel Ban List"},
/* 369 */
    {RPL_ENDOFWHOWAS, "%s :End of WHOWAS"},
/* 370 */
    {0, (char *) NULL},
/* 371 */
    {RPL_INFO, ":%s"},
/* 372 */
    {RPL_MOTD, ":- %s"},
/* 373 */
    {RPL_INFOSTART, ":Server INFO"},
/* 374 */
    {RPL_ENDOFINFO, ":End of /INFO list."},
/* 375 */
    {RPL_MOTDSTART, ":- %s Message of the Day - "},
/* 376 */
    {RPL_ENDOFMOTD, ":End of /MOTD command."},
/* 377 */
    {0, (char *) NULL},
/* 378 */
    {RPL_WHOISHOST, "%s %s :Real nick@host"},
/* 379 */
    {0, (char *) NULL},
/* 380 */
    {0, (char *) NULL},
/* 381 */
    {RPL_YOUREOPER, ":You are now an IRC Operator"},
/* 382 */
    {RPL_REHASHING, "%s :Rehashing at %s"},
/* 383 */
    {RPL_YOURESERVICE, (char *) NULL},
/* 384 */
    {RPL_MYPORTIS, "%d :Port to local server is\r\n"},
/* 385 */
    {RPL_NOTOPERANYMORE, (char *) NULL},
/* 386 */
    {RPL_HOSTRESTRICTLIST, "%s %s %s %lu"},
/* 387 */
    {RPL_HOSTRESTRICTLISTEND, "%s :End of Channel Host Restrict List"},
/* 388 */
    {0, (char *) NULL},
/* 389 */
    {0, (char *) NULL},
/* 390 */
    {0, (char *) NULL},
/* 391 */
    {RPL_TIME, "%s :%s"},
/* 392 */
    {0, (char *) NULL},
/* 393 */
    {0, (char *) NULL},
/* 394 */
    {0, (char *) NULL},
/* 395 */
    {0, (char *) NULL},
/* 396 */
    {0, (char *) NULL},
/* 397 */
    {0, (char *) NULL},
/* 398 */
    {0, (char *) NULL},
/* 399 */
    {0, (char *) NULL},
/* 400 */
    {RPL_TRACELINK, "Link %s%s %s %s"},
/* 201 */
    {RPL_TRACECONNECTING, "Attempt %d %s"},
/* 202 */
    {RPL_TRACEHANDSHAKE, "Handshaking %d %s"},
/* 203 */
    {RPL_TRACEUNKNOWN, "???? %d %s"},
/* 204 */
    {RPL_TRACEOPERATOR, "Operator %d %s %ld"},
/* 205 */
    {RPL_TRACEUSER, "User %d %s %ld"},
/* 206 */
    {RPL_TRACESERVER, "Server %d %dS %dC %s %s!%s@%s %ld"},
/* 207 */
    {RPL_TRACESERVICE, "Service %d %s"},
/* 208 */
    {RPL_TRACENEWTYPE, "<newtype> 0 %s"},
/* 209 */
    {RPL_TRACECLASS, "Class %d %d"},
/* 210 */
    {0, (char *) NULL},
/* 211 */
    {RPL_STATSLINKINFO, (char *) NULL},
#ifdef DEBUGMODE
/* 212 */
    {RPL_STATSCOMMANDS, "%s %u %u %u %u %u %u"},
#else
/* 212 */
    {RPL_STATSCOMMANDS, "%s %u %u"},
#endif
/* 213 */
    {RPL_STATSCLINE, "%c %s * %s %d %d"},
/* 214 */
    {RPL_STATSNLINE, "%c %s * %s %d %d"},
/* 215 */
    {RPL_STATSILINE, "%c %s * %s %d %d"},
/* 216 */
    {RPL_STATSKLINE, "%c %s %s %s %d %d"},
/* 217 */
    {RPL_STATSQLINE, "%c %s %s %s %d %d"},
/* 218 */
    {RPL_STATSYLINE, "%c %d %d %d %d %ld"},
/* 219 */
    {RPL_ENDOFSTATS, "%c :End of /STATS report"},
/* 220 */
    {RPL_STATSBLINE, "%c %s"},
/* 221 */
    {RPL_UMODEIS, "%s"},
/* 222 */
    {RPL_SQLINE_NICK, "%s :%s"},
/* 223 */
    {RPL_STATSFLINE, "%c %s * * * *"},
/* 224 */
    {0, (char *) NULL},
/* 225 */
    {0, (char *) NULL},
/* 226 */
    {0, (char *) NULL},
/* 227 */
    {0, (char *) NULL},
/* 228 */
    {0, (char *) NULL},
/* 229 */
    {0, (char *) NULL},
/* 230 */
    {0, (char *) NULL},
/* 231 */
    {RPL_SERVICEINFO, (char *) NULL},
/* 232 */
    {RPL_ENDOFSERVICES, (char *) NULL},
/* 233 */
    {RPL_SERVICE, (char *) NULL},
/* 234 */
    {RPL_SERVLIST, (char *) NULL},
/* 235 */
    {RPL_SERVLISTEND, (char *) NULL},
/* 236 */
    {RPL_JINX, "%s :%s"},
    {RPL_STATSJINX, "J %s :%s"},
    {0, (char *) NULL},
    {0, (char *) NULL},
    {0, (char *) NULL},
/* 241 */
    {RPL_STATSLLINE, "%c %s * %s %d %d"},
/* 242 */
    {RPL_STATSUPTIME, ":Server Up \2%d\2 day(s), %d:%02d:%02d"},
/* 243 */
    {RPL_STATSOLINE, "%c %s * %s %u %d"},
/* 244 */
    {RPL_STATSHLINE, "%c %s * %s %d %d"},
/* 245 */
    {RPL_STATSSLINE, "%c %s * %s %d %d"},
    {0, (char *) NULL},
/* 247 */
    {RPL_STATSXLINE, "X %s %d"},
/* 248 */
    {RPL_STATSULINE, "%c %s * %s %d %d"},
    {0, (char *) NULL},
/* 250 */
    {RPL_STATSCONN, ":Highest connection count: %d (%d client(s))"},
/* 251 */
    {RPL_LUSERCLIENT,
     ":There are %d user(s) and %d invisible on %d server(s)"},
/* 252 */
    {RPL_LUSEROP, "%d :operator(s) online"},
/* 253 */
    {RPL_LUSERUNKNOWN, "%d :unknown connection(s)"},
/* 254 */
    {RPL_LUSERCHANNELS, "%d :channel(s) formed"},
/* 255 */
    {RPL_LUSERME, ":I have %d client(s) and %d server(s)"},
/* 256 */
    {RPL_ADMINME, ":Administrative info about %s"},
/* 257 */
    {RPL_ADMINLOC1, ":%s"},
/* 258 */
    {RPL_ADMINLOC2, ":%s"},
/* 259 */
    {RPL_ADMINEMAIL, ":%s"},
    {0, (char *) NULL},
/* 261 */
    {RPL_TRACELOG, "File %s %d"},
    {0, (char *) NULL},
    {0, (char *) NULL},
    {0, (char *) NULL},
/* 265 */
    {RPL_LOCALUSERS, ":Current local users: %d  Max: %d"},
/* 266 */
    {RPL_GLOBALUSERS, ":Current global users: %d  Max: %d"},
    {0, (char *) NULL},
    {0, (char *) NULL},
    {0, (char *) NULL},
    {0, (char *) NULL},
/* 271 */
    {RPL_SILELIST, "%s %s"},
/* 272 */
    {RPL_ENDOFSILELIST, ":End of Silence List"},
    {0, (char *) NULL},
    {0, (char *) NULL},
/* 275 */
    {RPL_STATSDLINE, "%c %s %s"},
    {0, (char *) NULL}
};

/*
 * NOTE: Unlike the others, this one goes strait through, 600-799
 */
static Numeric numeric_replies2[] = {
/* 600 */
    {RPL_LOGON, "%s %s %s %d :logged online"},
/* 601 */
    {RPL_LOGOFF, "%s %s %s %d :logged offline"},
/* 602 */
    {RPL_WATCHOFF, "%s %s %s %d :stopped watching"},
/* 603 */
    {RPL_WATCHSTAT, ":You have %d and are on %d WATCH entries"},
/* 604 */
    {RPL_NOWON, "%s %s %s %d :is online"},
/* 605 */
    {RPL_NOWOFF, "%s %s %s %d :is offline"},
/* 606 */
    {RPL_WATCHLIST, ":%s"},
/* 607 */
    {RPL_ENDOFWATCHLIST, ":End of WATCH %c"},
/* 608 */
    {RPL_WATCHCLEAR, ":Your WATCH list is now empty"},
/* 609 */
    {RPL_OMOTDSTART, ":%s IRC Operator MOTD"},
/* 610 */
    {RPL_OMOTD, ":- %s"},
/* 611 */
    {RPL_ENDOFOMOTD, ":End of IRC Operator MOTD."},
/* 612 */
    {RPL_WHOWASIP, ":%s was using IP %s."},
/* 613 */
    {RPL_STATSGZLINE, "%c %s %s %s %i %i %s"},
/* 614 */
    {RPL_WHOISMODES, ":%s (%s) is using modes: %s"},
/* 615 */
    {RPL_MAPMORE, ":%s%-*s --> *more*"},
/* 616 */
    {RPL_POLICY,
     ":Welcome to AstralIRC, \2%s\2! Using this network constitutes agreement with our Acceptable Use Policy. You may view our policy at www.xivservers.net/irc/aup.php"},
/* 617 */
    {ERR_HTCTOOFAST,
     ":You are sending too fast. Please wait %i seconds before sending new commands."},
    {0, (char *) NULL}
};

char *err_str (numeric)
     int numeric;
{
    Numeric *nptr;
    int num = numeric;

    num -= numeric_errors[0].num_val;
    if (num < 0 || num > ERR_NEEDPONG)
	(void) sprintf (numbuff,
			":%%s %d %%s :INTERNAL ERROR: BAD NUMERIC! %d",
			numeric, num);
    else {
	nptr = &numeric_errors[num];
	if (!nptr->num_form || !nptr->num_val)
	    (void) sprintf (numbuff,
			    ":%%s %d %%s :NO ERROR FOR NUMERIC ERROR %d",
			    numeric, num);
	else
	    (void) prepbuf (numbuff, nptr->num_val, nptr->num_form);
    }
    return numbuff;
}


char *rpl_str (numeric)
     int numeric;
{
    Numeric *nptr;
    int num = numeric;

    if (num > 99)
	num -= (num > 300) ? 300 : 100;

    if ((num < 0 || num > 200) && (num < 300 || num > 499))
	(void) sprintf (numbuff,
			":%%s %d %%s :INTERNAL REPLY ERROR: BAD NUMERIC! %d",
			numeric, num);
    else {
	if (numeric > 599) {
	    num -= 300;
	    nptr = &numeric_replies2[num];
	}
	else if (numeric > 99)
	    nptr = &numeric_replies[num];
	else
	    nptr = &local_replies[num];
	Debug ((DEBUG_NUM, "rpl_str: numeric %d num %d nptr %x %d %x",
		numeric, num, nptr, nptr->num_val, nptr->num_form));
	if (!nptr->num_form || !nptr->num_val)
	    (void) sprintf (numbuff,
			    ":%%s %d %%s :NO REPLY FOR NUMERIC ERROR %d",
			    numeric, num);
	else
	    (void) prepbuf (numbuff, nptr->num_val, nptr->num_form);
    }
    return numbuff;
}

static char *prepbuf (buffer, num, tail)
     char *buffer;
     int num;
     char *tail;
{
    char *s;

    (void) strcpy (buffer, ":%s ");
    s = buffer + 4;

    *s++ = numbers[num / 100];
    num %= 100;
    *s++ = numbers[num / 10];
    *s++ = numbers[num % 10];
    (void) strcpy (s, " %s ");
    (void) strcpy (s + 4, tail);
    return buffer;
}
